package be.kdg.bombermanunlimited.client;

import java.util.HashMap;
import java.util.Map;

/**
 * Een centrale registry waar veel objecten geregistreerd worden die veel
 * verschillende componenten nodig hebben.
 * 
 * @author Philip
 * 
 */
public class CentralRegistry {
	public enum BombermanObjects {
		PLAYERS, LOCAL_IP, RING_PORT, HOST_IP, HOST_PORT, MUSIC_DIRECTORY, USERNAME
	}

	private static final CentralRegistry registry = new CentralRegistry();

	private Map<BombermanObjects, Object> objects;

	public CentralRegistry() {
		objects = new HashMap<BombermanObjects, Object>();
	}

	public void putObject(BombermanObjects key, Object o) {
		if (key.equals(BombermanObjects.MUSIC_DIRECTORY)) {
			String str = (String) o;
			if (!str.endsWith("\\")) {
				str += "\\";
				o = str;
			}
		}
		objects.put(key, o);
	}

	public Object getObject(BombermanObjects key, Object o) {
		return objects.get(key);
	}

	public String getString(BombermanObjects key) {
		return (String) objects.get(key);
	}

	public int getInteger(BombermanObjects key) {
		return (Integer) objects.get(key);
	}

	public static CentralRegistry getRegistry() {
		return registry;
	}
}
